import { loadBMap } from './bmap-loader'

export async function initBMap(containerId, center = [116.404, 39.915], zoom = 16) {
    await loadBMap() // 确保 BMapGL 已加载

    const container = document.getElementById(containerId)
    if (!container) throw new Error(`容器 #${containerId} 未找到`)

    const map = new BMapGL.Map(container)
    map.centerAndZoom(new BMapGL.Point(center[0], center[1]), zoom)
    map.enableScrollWheelZoom(true)

    return map
}